<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>demo</title>
<script src="./dist/WebscanQrcode.bundle.js"></script>
</head>
<body>
    <video id="preview" autoplay controls="true" webkit-playsinline="true" playsinline="true"></video>
    <script>
        var allCameras = [];
        var activeCamera = null
        var scanner = new WebscanQrcode.Scanner({
            video: document.getElementById('preview'),
            scanPeriod: 5,
            mirror:false,//不用镜像模式，镜像模式类似于镜子
        });
        scanner.addListener('scan', function (content, image) {
            console.log({ date: +Date.now(), content: content });
        });
        WebscanQrcode.Camera.getCameras()
            .then(function (cameras) {
                allCameras = cameras
                activeCamera = cameras[0]
                //开始扫描的方法
                scanner.start(activeCamera,'auto')
            })
            .catch(function (e) {
                alert('error message：'+e)
                console.error(e);
            });
    </script>
</body>
</html>
